<?php 
class oDb_attribute_detail extends MVC_SQL {
	public function __construct(){
		$this->setTable('attribute_detail');
	}
	public function getdataAttribute($oModel)
	{
		$sql = "SELECT * FROM attribute_detail ad 
		inner join attribute a on ad.at_id=a.at_id
		ORDER BY ad.atd_id DESC";
		return  $this->getRecordsetExtend($sql);
	}
	public function delete_att($at_id){
		$sql = "DELETE FROM attribute_detail WHERE at_id ='{$at_id}' ";
		return  $this->db_query($sql);
	}
	//select ra name cua cac attribute
	public function getNameAttribute($oModel)
	{
		$sql="SELECT at_id,at_Name FROM attribute ORDER BY at_id";
		return  $this->getRecordsetExtend($sql);
	}
	//lay ra thong tin cua attribute cho viec update sau
	public function getInfoAttribute($at_id)
	{
		$sql="SELECT * FROM attribute_detail WHERE at_id='{$at_id}'";
		return  $this->getRecordsetExtend($sql);	
	}	
	public function getInfoAttribute_parent($atd_id)
	{
		$sql="SELECT * FROM attribute_detail WHERE atd_id='{$atd_id}'";
		return  $this->getRecordsetExtend($sql);	
	}	
	public function insert_att($at,$attd_name,$attd_status)
	{
		$sql="INSERT INTO attribute_detail(at,atd_name,atd_status) VALUES ('$at','$attd_name','$attd_status') ";
		//echo $sql;
		//die();
		return  $this->db_query($sql);	
	}
	public function update_att($attd_id,$att_id,$att_name,$att_status)
	{
		$sql="UPDATE attribute_detail SET at='{$att_id}'atd_name='{$att_name}',atd_status='{$att_status}' WHERE atd_id={$attd_id} ";
		//echo $sql;
		//die();
		return  $this->db_query($sql);	
	}
}
?>
